package com.xjy.ftpmanagment.command;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.xjy.common.util.ConfigUtil;
import com.xjy.common.util.PathUtil;

/**
 * sustat参数
 * @author Lee
 *
 */
public class SustatConstant {
	public static String FTP_LOG_PATH = (null == ConfigUtil.getConfig("ftp.logpath")? PathUtil.getContextPath() : ConfigUtil.getConfig("ftp.logpath"));
	public static String FTP_LOG_FILE = (null == ConfigUtil.getConfig("ftp.logfile")? "<date>.txt": ConfigUtil.getConfig("ftp.logfile"));
	public static String FTP_LOG_FILE_FORMAT = (null == ConfigUtil.getConfig("ftp.logfile.format")? "yyyy-MM-dd" : ConfigUtil.getConfig("ftp.logfile.format"));
	
	public static final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
	public static final long ONE_DAY = 24 * 60 * 60 * 1000;
	public static final int TYPE_STAT_USER = 0;
	public static final int TYPE_STAT_FILE = 1;
	public static final int TYPE_STAT_IP = 2;
	
	public static String getDay(Timestamp time) {
		return getDay(time, 0);
	}
	
	public static String getDay(Timestamp time, int day) {
		return formatter.format(new Date(time.getTime() + day * ONE_DAY));
	}
}
